<?php
/**
 * 首页控制器类
 * User: mrlifang
 * Date: 17/5/4
 * Time: 下午12:49
 */

namespace Home\Controller;
use Frame\Libs\BaseController;
use  Home\Model\IndexModel; //引入IndexModel类
final class IndexController extends BaseController
{
    //首页显示方法
    public function index(){
        //① 创建模型类对象
        //$modelObj = IndexModel::getInstance("\\Home\\Model\\IndexModel");
        $modelObj = IndexModel::getInstance();
        
        //② 获取多行数据
        $arrs = $modelObj->fetchAll();

        //向视图赋值,并调用视图显示
        $this->smarty->assign("arrs",$arrs);
        $this->smarty->display("Index".DS."index.html");
    }

    //删除记录
    public function delete(){
        //获取地址栏的id
        $id = $_GET["id"];
        //创建模型类对象
        $modelObj = IndexModel::getInstance();
        //调用模型类对象的delete()方法
        $modelObj->delete($id);
        $this->jump("id={$id}的记录删除成功!","?c=Index");

    }

}